﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using KPIS.GERP.ESS.BLL;
using KPIS.GERP.ESS.MODEL;
using KPIS.GERP.GFMS.APP.App_UI.Commons;
using KPIS.GERP.GFMS.IBLL;
using KPIS.GERP.GFMS.BLL;
using KPIS.GERP.GFMS.MODEL;


namespace KPIS.GERP.GFMS.APP.App_UI.UserControls
{
    public partial class Reply : System.Web.UI.UserControl
    {
        Main main = new Main();
        B_MessageSend send = new B_MessageSend();
        B_MessageReply reply = new B_MessageReply();

        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public void LoadData(string strReplySeq)
        {
            M_MessageReply Info = reply.GetInfo(strReplySeq);
            lblReplySeq.Text = strReplySeq;
            lblSendSeq.Text = Info.from_send_seq.ToString();
            lblRefNo.Text = Info.ref_no;
            lblReplyDate.Text = Info.reply_date.Value.ToShortDateString();
            lblEmpName.Text = Info.from_user_name;
            lblReplyText.Text = Info.reply_text;

            M_MessageSend SendInfo = send.GetInfo(lblSendSeq.Text);
            lblSendRefNo.Text = SendInfo.ref_no;
            lblSendDate.Text = SendInfo.send_date.Value.ToShortDateString();
            lblSendText.Text = SendInfo.send_text;

            UpdateSendMessageStatus(strReplySeq, "1");
        }

        protected void UpdateSendMessageStatus(string strReplySeq, string strMessageStatus)
        {
            string strUserID = Session["EmpSeq"].ToString();
            M_MessageReply info = new M_MessageReply();

            info.reply_seq = Convert.ToInt32(strReplySeq);
            info.message_status = strMessageStatus;
            info.updated_by = main.ConvertNullInt(Session["EmpSeq"]);
            info.updated_when = DateTime.Now;

            reply.UpdateMessageStatus(info);
        }

        protected void cmdCancel_Click(object sender, EventArgs e)
        {
            ((Forms.TaskLists)this.Parent.Page).ViewReply();
        }
    }
}